
use macroquad::prelude::*;


pub mod math
{
    use crate::data::math::*;


    pub fn draw_line(segment: Segment, color: super::Color)
    {
        super::draw_line(
            segment.point1.x as f32,
            segment.point1.y as f32,
            segment.point2.x as f32,
            segment.point2.y as f32,
            15.0,
            color
        );
    }


    pub fn draw_rectangle(r: Rectangle, color: super::Color)
    {
        super::draw_rectangle(
            r.left as f32,
            r.top as f32,
            (r.right - r.left) as f32,
            (r.bottom - r.top) as f32,
            color
        );
    }
}





#[cfg(test)]
mod tests {
    use super::*;
    use crate::data::math::*;

    #[macroquad::test]
    async fn test_draw()
    {
        loop {
            clear_background(BLACK);
    
            draw_line(40.0, 40.0, 100.0, 200.0, 15.0, BLUE);
            draw_rectangle(screen_width() / 2.0 - 60.0, 100.0, 120.0, 60.0, GREEN);
            draw_circle(screen_width() - 30.0, screen_height() - 30.0, 15.0, YELLOW);
    
            draw_text("IT WORKS!", 20.0, 20.0, 30.0, DARKGRAY);
    
            next_frame().await
        }
    }


    #[macroquad::test]
    async fn test_draw_rect()
    {
        loop
        {
            clear_background(BLACK);
            math::draw_rectangle(
                Rectangle { left: 0.0, right: 100.0, top: 0.0, bottom: 100.0 },
                WHITE
            );
            next_frame().await
        }
    }
}

